<template>
  <div class="app-container">
    <el-form :model="searchForm" :inline="true">
      <el-row>
        <el-col :span="19">
          <el-form-item>
            <el-input v-model="searchForm.offerId" placeholder="关联报价单号" clearable @keyup.enter.native="handleSearch" />
          </el-form-item>
          <el-form-item>
            <el-input v-model="searchForm.projectName" placeholder="项目名称" clearable @keyup.enter.native="handleSearch" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" class="iconfont icon-chaxun1" @click="handleSearch"> 查询</el-button>
          </el-form-item>
        </el-col>
        <el-col :span="5" class="search-right">
          <el-button type="text" icon="el-icon-refresh" @click="handleSearch">刷新</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      class="table-fixed-class"
      border
      :data="offermonreviewhisData"
      stripe
      highlight-current-row
      :header-cell-style="{background:'#ECF3FC'}"
    >
      <el-table-column type="index" width="50" label="序号" align="center" />
      <el-table-column prop="projectName" label="项目名称" width="140px" align="center" />
      <el-table-column prop="offerId" label="关联报价单号" width="190px" align="center" />
      <el-table-column prop="jcfamc" label="监测方案名称" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" v-if="element.monitorName === null || element.monitorName === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
              <el-button type="text" v-if="element.monitorName != null && element.monitorName != ''" style="color: #606266;cursor: default;">{{ element.monitorName }}</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="glrwdh" label="关联任务单号" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-tooltip effect="dark" placement="top" v-if="element.relationTaskCode != null && element.relationTaskCode != ''">
                <div slot="content" style="max-width: 210px">
                  {{ element.relationTaskCode}}<el-button type="text">&nbsp;</el-button>
                </div>
                <div class="apostrophe">
                  <span>{{ element.relationTaskCode}}<el-button type="text">&nbsp;</el-button></span>
                </div>
              </el-tooltip>
              <el-button type="text" v-if="element.relationTaskCode === null || element.relationTaskCode === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="fazt" label="方案状态" width="120px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <span v-if="element.judgeStatus === '0'"><el-button type="text" style="color: #fff;cursor: default;background-color: #1890ff;padding-left: 5px;padding-right: 5px;">待评审</el-button></span>
              <span v-if="element.judgeStatus === '1'"><el-button type="text" style="color: #fff;cursor: default;background-color: rgb(17, 185, 92);padding-left: 5px;padding-right: 5px;">评审通过</el-button></span>
              <span v-if="element.judgeStatus === '2'"><el-button type="text" style="color: #fff;cursor: default;background-color: rgb(255, 73, 73);padding-left: 5px;padding-right: 5px;">驳回</el-button></span>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="fabzr" label="方案编制人" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" style="color: #606266;cursor: default;">{{ element.schemeUserName }}</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="fashr" label="方案审核人" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-tooltip effect="dark" placement="top" v-if="element.reviewerUserName != null && element.reviewerUserName != ''">
                <div slot="content" style="max-width: 210px">
                  {{ element.reviewerUserName}}<el-button type="text">&nbsp;</el-button>
                </div>
                <div class="apostrophe">
                  <span>{{ element.reviewerUserName}}<el-button type="text">&nbsp;</el-button></span>
                </div>
              </el-tooltip>
              <el-button type="text" v-if="element.reviewerUserName === null || element.reviewerUserName === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="tjpssj" label="提交评审时间" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" style="color: #606266;cursor: default;">{{ element.reviewerTime }}</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column label="操作" fixed="right" align="center" width="240px">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" @click="downloadMonScheme(element)">下载</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
    </el-table>
    <div style="float: right">
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="searchForm.pageNumber"
        :limit.sync="searchForm.pageSize"
        @pagination="handleSearch"/>
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import * as offermonitorServer from '@/api/offermonitor'

export default {
  components: { Pagination},
  data() {
    return {
      searchForm: {
        offerId: '',
        projectName: '',
        pageNumber: 1,
        pageSize: 10
      },
      total: 0,
      offermonreviewhisData: [],
    }
  },

  created() {
    this.handleSearch()
  },

  methods: {
    handleSearch() {
      offermonitorServer.findOfferMonitorHisReview(this.searchForm).then(res => {
        if (res.code === 200 && res.result) {
          this.offermonreviewhisData = res.result.records || []
          this.total = res.result.total
        }
      })
    },

    // 原始或者最新方案下载
    downloadMonScheme(row) {
      if (row.monitorNewFileId !== null && row.monitorNewFileId.length > 0) {
        var urllast = this.$store.getters.sysBaseUrl + '/file/ht/upload/' + row.monitorNewFileId
        window.open(urllast)
      }else {
        if (row.monitorFileId !== null && row.monitorFileId.length > 0){
          var urlhis = this.$store.getters.sysBaseUrl + '/file/ht/upload/' + row.monitorFileId
          window.open(urlhis)
        }else {
          this.$message.error('方案下载失败！')
        }
      }
    },

  }
}
</script>

<style scoped lang="scss" type="text/scss">
.search_div {
  >div {
    &:nth-child(1){
      margin-right: 10px;
    }
    display: inline-block;
  }
}
.search_input {
  width: 200px;
  margin-bottom: 5px;
}
.search-right {
  text-align: right;
  padding-right: 25px;
}
.item {
  font-size: 16px;
}
::v-deep .el-card .el-card__header {
  padding: 5px 20px;
  background: #F3F2F2;
}
.apostrophe{
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.table2  {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
/deep/ .vue-treeselect--disabled .vue-treeselect__single-value{
  color: #909399
}
.container2 {
  width: 680px;
  height: 620px;
  overflow: auto;
  overflow-x: hidden;
  margin-left: 250px;
  margin-top: -525px;
}
/deep/ .wl-transfer .transfer-main {
  padding: 10px;
  height: calc(100% - 80px);
  box-sizing: border-box;
  overflow: auto;
}
.table-fixed-class /deep/ .el-table__fixed-right{
  height: 100% !important;
}
.el-button{
  user-select: unset;
}
</style>
